import request from '@/utils/request'
import { API_USER_REGISTER,
  API_SEND_CODE,
  API_USER_LOGIN,
  API_TEST,
  API_GET_WIXIN_PAY_URL,
  API_CHECK_PAY_STATUS_URL,
  API_GET_CAROUSEL,
  API_GET_CATEGORY,
  API_GET_CAPTCHA,
  API_CHECK_CAHPTCHA,
  API_SEARCH_SUGREC,
  API_GET_SEARCH_RESULT,
  API_GET_GRAPH_CONFIG,
  API_SHOW_SHOP_COURSE
} from '@/constants/api'

export function register (data) {
  return request.post(API_USER_REGISTER,data)
}

export function sendCode (data) {
  return request.post(API_SEND_CODE,data)
}

export function login (data) {
  return request.post(API_USER_LOGIN,data)
}

export function getCaptcha () {
  return request.get(API_GET_CAPTCHA)
}

export function checkChaptcha (id,data) {
  return request.post(API_CHECK_CAHPTCHA+id,data)
}

export function test () {
  return request.get(API_TEST)
}

export function getWeiXinQrCode (out_trade_no,total_fee) {
  return request.get(API_GET_WIXIN_PAY_URL+"?out_trade_no="+out_trade_no+"&total_fee="+total_fee)
}

export function checkPayStatusCode (out_trade_no) {
  return request.get(API_CHECK_PAY_STATUS_URL+"?out_trade_no="+out_trade_no)
}

export function getCarousel () {
  return request.get(API_GET_CAROUSEL)
}

export function getGategoryList () {
  return request.get(API_GET_CATEGORY)
}

// ================================== 搜索 ====================================
export function getSuggest (pwd) {
  return request.get(API_SEARCH_SUGREC+pwd)
}

export function getSearchResult (keyword,idx) {
  return request.get(API_GET_SEARCH_RESULT+"?keyword="+keyword+"&idx="+idx)
}

// ================================ 图数据库 =================================
export function getGraphConfig () {
  return request.get(API_GET_GRAPH_CONFIG)
}

// ================================ 商城 ===================================
export function getShopCourseData () {
  return request.get(API_SHOW_SHOP_COURSE)
}
